import axios from 'axios'
import store from '../store'
const instance = axios.create({
    baseURL: 'http://kumanxuan1.f3322.net:8001',
    timeout: 5000
})

// 请求拦截【instance.interceptors.request.use(cb, cb)】
instance.interceptors.request.use(config => {
    // config.headers.token = "xxxx"
    const token =localStorage.getItem("token");
    if(token){
        config.headers["X-Nideshop-Token"]=token;
    }
    return config
}, err => {
    return Promise.reject(err)
})

// 响应拦截【instance.interceptors.response.use(cb, cb)】
instance.interceptors.response.use(result => {
    return result.data;
}, err => {
    return Promise.reject(err)
})

export default instance;